package com.ruoyi.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.domain.AppActivityTags;
import com.ruoyi.app.service.IAppActivityTagsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动自选标签（存储所有可选标签）Controller
 * 
 * @author ruoyi
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/app/tags")
public class AppActivityTagsController extends BaseController
{
    @Autowired
    private IAppActivityTagsService appActivityTagsService;

    /**
     * 查询活动自选标签（存储所有可选标签）列表
     */
    @PreAuthorize("@ss.hasPermi('app:tags:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppActivityTags appActivityTags)
    {
        startPage();
        List<AppActivityTags> list = appActivityTagsService.selectAppActivityTagsList(appActivityTags);
        return getDataTable(list);
    }

    /**
     * 导出活动自选标签（存储所有可选标签）列表
     */
    @PreAuthorize("@ss.hasPermi('app:tags:export')")
    @Log(title = "活动自选标签（存储所有可选标签）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppActivityTags appActivityTags)
    {
        List<AppActivityTags> list = appActivityTagsService.selectAppActivityTagsList(appActivityTags);
        ExcelUtil<AppActivityTags> util = new ExcelUtil<AppActivityTags>(AppActivityTags.class);
        util.exportExcel(response, list, "活动自选标签（存储所有可选标签）数据");
    }

    /**
     * 获取活动自选标签（存储所有可选标签）详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:tags:query')")
    @GetMapping(value = "/{tagId}")
    public AjaxResult getInfo(@PathVariable("tagId") Long tagId)
    {
        return success(appActivityTagsService.selectAppActivityTagsByTagId(tagId));
    }

    /**
     * 新增活动自选标签（存储所有可选标签）
     */
    @PreAuthorize("@ss.hasPermi('app:tags:add')")
    @Log(title = "活动自选标签（存储所有可选标签）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppActivityTags appActivityTags)
    {
        return toAjax(appActivityTagsService.insertAppActivityTags(appActivityTags));
    }

    /**
     * 修改活动自选标签（存储所有可选标签）
     */
    @PreAuthorize("@ss.hasPermi('app:tags:edit')")
    @Log(title = "活动自选标签（存储所有可选标签）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppActivityTags appActivityTags)
    {
        return toAjax(appActivityTagsService.updateAppActivityTags(appActivityTags));
    }

    /**
     * 删除活动自选标签（存储所有可选标签）
     */
    @PreAuthorize("@ss.hasPermi('app:tags:remove')")
    @Log(title = "活动自选标签（存储所有可选标签）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagIds}")
    public AjaxResult remove(@PathVariable Long[] tagIds)
    {
        return toAjax(appActivityTagsService.deleteAppActivityTagsByTagIds(tagIds));
    }
}
